package cn.shujuhai.qtadmin.platform.exception;

import org.jetbrains.annotations.NotNull;

/**
 * @author dch
 */
public class DefinitionException extends RuntimeException {
    private final Integer errorCode;
    private final String errorMsg;

    /**
     * @param errorCode
     *            错误码
     * @param errorMsg
     *            错误消息
     */
    public DefinitionException(Integer errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    /**
     * @param errorMsg
     *            错误消息
     */
    public DefinitionException(String errorMsg) {
        this.errorCode = 500;
        this.errorMsg = errorMsg;
    }

    /**
     *
     * @param exception
     *            异常信息
     */
    public DefinitionException(@NotNull Exception exception) {
        this.errorCode = 500;
        this.errorMsg = exception.getMessage();
        exception.printStackTrace();
    }

    /**
     * @return 错误码
     */
    public Integer getErrorCode() {
        return errorCode;
    }

    /**
     * @return 错误消息
     */
    public String getErrorMsg() {
        return errorMsg;
    }
}
